// 获取当前标签页信息
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
  const tab = tabs[0];
  document.getElementById('title').textContent = `标题：${tab.title}`;
  document.getElementById('url').textContent = `URL：${tab.url}`;
});

// 点击按钮修改页面背景色
document.getElementById('changeBg').addEventListener('click', () => {
  const colors = ['#ffcccc', '#ccffcc', '#ccccff', '#ffffcc'];
  const randomColor = colors[Math.floor(Math.random() * colors.length)];

  // 向内容脚本发送消息
  chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
    chrome.tabs.sendMessage(tabs[0].id, { action: "changeBg", color: randomColor });
  });
});